
using System.Web.UI.HtmlControls;
using System;
using System.Configuration;
using System.Drawing;
using System.Data;
using System.Web.UI.WebControls;
using Microsoft.VisualBasic;
using System.Collections;
using System.Web.UI;
using System.Web;


using System.Text;
//using com.ddsc.database;
using DDSC.OracleADO;


namespace smasb2b
{
	public class EMPD0012 : BasePage
	{
		
#region  Web Form 設計工具產生的程式碼
		
		//此為 Web Form 設計工具所需的呼叫。
		[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
		{
			
		}
		protected System.Web.UI.WebControls.Label lblName;
		protected System.Web.UI.WebControls.Label lblEMP_ID;
		protected System.Web.UI.WebControls.Label lblTel;
		protected System.Web.UI.WebControls.Repeater rpOrder;
		protected System.Web.UI.WebControls.Label lblTotal;
		protected System.Web.UI.WebControls.Literal litPayType;
		
		//注意: 下列預留位置宣告是 Web Form 設計工具需要的項目。
		//請勿刪除或移動它。
		private System.Object designerPlaceholderDeclaration;
		
		private void Page_Init(System.Object sender, System.EventArgs e)
		{
			//CODEGEN: 此為 Web Form 設計工具所需的方法呼叫
			//請勿使用程式碼編輯器進行修改。
			InitializeComponent();
		}
		
#endregion
		
		private void Page_Load(System.Object sender, System.EventArgs e)
		{
			//在這裡放置使用者程式碼以初始化網頁
			
			if (!IsPostBack)
			{
				if (!(Request["o"] == null))
				{
					FunctionHandler fn = new FunctionHandler();
					loadOrder(fn.Decrypt(Request["o"]));
				}
			}
		}
		
		private void loadOrder(string strOrderNo)
		{
			dbAccess dba = new dbAccess();
			StringBuilder sb = new StringBuilder();
            ArrayList m_arrParam = new ArrayList();
            //Ken : 1.修改SQL語法使用參數，不組字串s
			sb.AppendFormat(" SELECT * ");
			sb.AppendFormat("   FROM emp_order_master m, emp_order_details d ");
			sb.AppendFormat("  WHERE m.order_no = d.order_no ");
			//sb.AppendFormat("    AND m.order_no = \'{0}\'", strOrderNo);
            sb.AppendFormat("    AND m.order_no = :strOrderNo");
            //Ken : 2.設定動態參數物件
            m_arrParam.Add(dba.GetOracleParam(":strOrderNo",strOrderNo));
            //Ken : 3.修改執行方法Overload
            //DataSet ds = dba.runExecuteQuery("DATA", sb.ToString());
			DataSet ds = dba.runExecuteQuery("DATA", sb.ToString(), m_arrParam);

			if (ds.Tables[0].Rows[0]["ReturnCode"].ToString() == "000")
			{
				DataTable dt = ds.Tables["DATA"];
				DataRow dr = dt.Rows[0];
				int nSum = 0;
				
				lblName.Text = System.Convert.ToString(dr["CUST_NAME"].ToString());
				lblEMP_ID.Text = System.Convert.ToString(dr["EMP_ID"].ToString());
				lblTel.Text = System.Convert.ToString(dr["CUST_TEL"].ToString());
				litPayType.Text = System.Convert.ToString((dr["PAY_TYPE"].ToString() == "0") ? "現金" : "刷卡");
				
				for (int i = 0; i <= dt.Rows.Count - 1; i++)
				{
					dr = dt.Rows[i];
					
					nSum += int.Parse(System.Convert.ToString(dr["ORDER_AMT"].ToString()));
				}
				
				lblTotal.Text = nSum.ToString();
				rpOrder.DataSource = dt;
				rpOrder.DataBind();
			}
			
		}
		
	}
	
}
